function im = txtshow(fName,mode,h_size,v_size)

if(strcmp(mode,'gray'))
    color_byte = 1;
elseif(strcmp(mode,'rgb'))
    color_byte = 3;
else
    im = -1;
    return;
end

data = zeros(1,v_size*h_size*color_byte);
im = uint8(zeros(v_size,h_size,color_byte));
len = length(data);

fid = fopen(fName,'r');
for k = 1:len
    str = fgets(fid);
    data(k) = hex2dec(str(1:2));
end
fclose(fid);

for V=1:v_size
    row_s = (V - 1) * h_size*color_byte;
    if(color_byte==1)
        for H = 1:h_size
            im(V,H) = data(row_s+H);
        end
    elseif(color_byte==3)
        for H = 1:h_size
            im(V,H,1) = data(row_s+color_byte*(H-1)+1);
            im(V,H,2) = data(row_s+color_byte*(H-1)+2);
            im(V,H,3) = data(row_s+color_byte*(H-1)+3);
        end
    end
end
imshow(im);
